package com.stupidzhe.ds.algorithm;

import org.junit.Test;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;

/**
 * @Author: StupidZhe
 * @Date: Created in 2018/3/28
 * @Description: 选择排序
 */
public class SelectSort {

    public static List<Integer> sort(List<Integer> content) {
        int size = content.size();
        for (int n = 0; n < size; n++) {
            Integer tmp = content.get(n);
            for (int m = n; m < size; m++) {
                if (tmp > content.get(m)) {
                    tmp = content.get(m);
                }
            }
            content.set(n, tmp);
        }
        return content;
    }

    @Test
    public void test1() {
        LinkedList<Integer> con = new LinkedList<>();
        Random random = new Random(12312);
        for (int n = 0; n < 4000; n++)
            con.add(random.nextInt(100000));
        long start = System.currentTimeMillis();
        sort(con);
        System.out.println(System.currentTimeMillis() - start);
    }
}
